{include file="common/header-top" /}

<style>
    .step-span{
        font-size: 14px;
        font-weight: bold;
    }
    .chosed-job-type .van-grid-item__content{
        background:url("/__FRONT__/images/icon/check-job-type.png") no-repeat;
        background-size: 100%;
    }

    .van-cell-li{
        padding-top: 0px;
        padding-bottom: 0px;
        padding-right: 0px;
        min-height: 44px;
    }
    .van-cell-li .van-cell__left-icon{
        display: inline-block;
        padding-top: 10px;
    }
    .van-cell-li .van-cell__title span{
        display: inline-block;
        padding-top: 10px;
    }
    .van-cell-li .van-cell__value .van-field{
        background-color: #2aa24512;
        padding: 8px 10px;
        margin-top: 1px;
    }


    .job-detail-title-cell{
        padding: 3px 16px;
    }

    .job-detail-title{
        font-size: 18px;
        font-weight: 500;
    }

    .job-detail-money-cell{
        margin-top: 2px;
    }
    .job-detail-money{
        display: block;
        padding: 5% 10%;
    }
    .job-detail-money span{
        display: block;
        text-align: center;
        padding: 2% 0%;
    }
    .job-detail-article{
        font-size: .8rem;
        color: #2a2a2c;
        padding: 0% 4%;
    }

    .thirdStep-cell-li .van-cell__title{
        max-width: 26%;
    }

    .money-unit-btn{
        margin-left: 1.5%;
        margin-right: 1.5%;
        margin-bottom: 2%;
        border: 1px solid #a8a8a8;
    }
    .chose-money-unit-btn{
        background-color: #2aa245;
        color: #fff;
        font-size: 14px;
        font-weight: bold;
    }

    .van-uploader-img-logo{
        width: 75px;
        background:url("/__FRONT__/images/icon/goods-fm-icon.png") no-repeat;
        background-size: 75px 75px;
        opacity:0.4;
        filter:alpha(opacity=40); /* 针对 IE8 以及更早的版本 */
    }

    .van-uploader-imgs{
        background:url("/__FRONT__/images/icon/publish-goods-bg.png") no-repeat;
        background-size: 60px 60px;
        opacity:0.4;
        filter:alpha(opacity=40); /* 针对 IE8 以及更早的版本 */
    }


    .van-uploader__wrapper{
        height: 80px;
    }
    .van-uploader__upload{
        background-color: #fff0;
    }
    .van-uploader__upload-icon{
        color: #000000;
    }

</style>


<div id="app"  v-cloak>

    <van-nav-bar title="上架二手商品" left-arrow @click-left="goBack" left-text="返回"></van-nav-bar>

    <van-row>
        <van-col span="24">
            <van-steps
                    :active="currentStep"
                    active-icon="success"
            >
                <van-step>
                    <span class="step-span">二手商品类型</span>
                </van-step>
                <van-step>
                    <span class="step-span">商品详情</span>
                </van-step>
                <van-step>
                    <span class="step-span">预览发布</span>
                </van-step>
            </van-steps>
        </van-col>
    </van-row>



    <!--第一步-->
    <section v-show="firstStep">
        <van-row style="padding-bottom: 55px;">
            <van-cell
                    title="发布商品类型"
                    is-link arrow-direction="down"
                    icon="/__FRONT__/images/icon/publish-job-question.png"
                    style="font-weight: bold;font-size: 16px;"
            ></van-cell>

            <van-col span="24">
                <!--兼职类型-->
                <van-row>
                    <van-grid :column-num="4" square :border="false">
                        <van-grid-item
                                v-for="item in marketType"
                                :icon="item.img"
                                :text="item.name"
                                :class="item.style"
                                @click="clickMarketType(item)"
                        />
                    </van-grid>
                </van-row>
                <!--兼职类型-->

            </van-col>
        </van-row>
        <van-goods-action>
            <van-goods-action-button
                    type="danger"
                    text="下一步"
                    @click="firstStepBtn"
                    style="border-radius: 0px; margin-left: 0px;margin-right: 0px;"
                    color="#fc2820"
            />
        </van-goods-action>
    </section>
    <!--第一步-->


    <!--第二步-->
    <section v-show="secondStep">
        <div style="padding-bottom: 55px;">
            <van-row>
                <van-cell
                        title="商品名称"
                        icon="/__FRONT__/images/icon/goods-name.png"
                        style="font-weight: bold;font-size: 16px;"
                        :border="false"
                ></van-cell>
                <van-cell-group style="border: 1px solid #2aa24512; ">
                    <van-field
                            v-model="goodsInfo.name" placeholder="请输入商品名称"
                            required clearable
                            maxlength="100"
                            input-align="center"
                            border="false"
                            style="background-color: #2aa24512;"
                    ></van-field>
                </van-cell-group>
            </van-row>

            <van-row>
                <van-cell-group>

                    <van-cell
                            title="商品原价："
                            icon="/__FRONT__/images/icon/publish-job-money.png"
                            class="van-cell-li"
                    >
                        <van-field
                                v-model="goodsInfo.oprice"
                                input-align="center"
                                type="number"
                                slot="default"
                                border="false"
                                placeholder="请输入商品原价"
                        >
                            <van-icon slot="right-icon" style="font-size: 14px;font-weight: bold;">元</van-icon>
                        </van-field>
                    </van-cell>

                    <van-cell
                            title="成色："
                            icon="/__FRONT__/images/icon/goods-chengse.png"
                            class="van-cell-li"
                    >
                        <van-field
                                v-model="goodsInfo.depreciation"
                                input-align="center"
                                slot="default"
                                border="false"
                                placeholder="请输入商品几成新"
                        >
                        </van-field>

                    </van-cell>


                    <van-cell
                            title="商品售价："
                            icon="/__FRONT__/images/icon/goods-price.png"
                            class="van-cell-li"
                    >
                        <van-field
                                v-model="goodsInfo.money"
                                input-align="center"
                                type="number"
                                slot="default"
                                border="false"
                                placeholder="请输入商品售价"
                        >
                            <van-icon slot="right-icon" style="font-size: 14px;font-weight: bold;">元</van-icon>
                        </van-field>
                    </van-cell>

                    <van-cell
                            title="商品数量："
                            icon="/__FRONT__/images/icon/goods-num.png"
                            class="van-cell-li"
                    >
                        <van-field
                                v-model="goodsInfo.number"
                                input-align="center"
                                type="number"
                                slot="default"
                                border="false"
                        >
                            <van-icon slot="right-icon" style="font-size: 14px;font-weight: bold;">件</van-icon>
                        </van-field>

                    </van-cell>



                    <van-cell
                            title="卖家："
                            icon="/__FRONT__/images/icon/publish-job-contacts.png"
                            class="van-cell-li"
                    >
                        <van-field
                                v-model="goodsInfo.contacts"
                                input-align="center"
                                slot="default"
                                border="false"
                        >
                        </van-field>

                    </van-cell>

                    <van-cell
                            title="联系方式："
                            icon="/__FRONT__/images/icon/job-detail-mobile.png"
                            class="van-cell-li"
                    >
                        <van-cell-group slot="default">
                            <van-field
                                    v-model="goodsInfo.mobile"
                                    input-align="center"
                                    type="number"
                                    border="false"
                                    @blur="checkPhoneNum"
                                    :error-message="phone.error"
                                    placeholder="请输入手机号码"
                            >
                            </van-field>
                            <van-field
                                    v-model="goodsInfo.wechat_num"
                                    input-align="center"
                                    placeholder="请输入微信号"
                                    slot="default"
                                    type="text"
                                    border="false"
                            >
                            </van-field>

                            <van-field
                                    v-model="goodsInfo.qq_num"
                                    input-align="center"
                                    placeholder="请输入QQ号"
                                    slot="default"
                                    type="number"
                                    border="false"
                            >
                            </van-field>



                        </van-cell-group>
                    </van-cell>





                    <van-cell
                            title="区域："
                            icon="/__FRONT__/images/icon/publish-job-area.png"
                            is-link
                            :value="getLocation"
                            @click="clickShowSelectArea"
                    >
                    </van-cell>

                    <van-cell
                            title="卖家地址位置："
                            icon="/__FRONT__/images/icon/publish-job-address.png"
                            class="van-cell-li"
                    >
                        <van-field
                                v-model="goodsInfo.address"
                                input-align="center"
                                placeholder="请输入详细地址"
                                slot="default"
                                type="text"
                                border="false"
                        >
                        </van-field>

                    </van-cell>

                </van-cell-group>
            </van-row>


            <!--商品图片-->
            <van-row>
                <van-cell
                        title="商品图片"
                        icon="/__FRONT__/images/icon/publish-goods-img.png"
                        style="font-weight: bold;font-size: 16px;"
                        :border="false"
                ></van-cell>

                <van-col span="5">
                    <van-uploader
                            :after-read="afterReadUpload"
                            preview-size="95%"
                            class="van-uploader-img-logo"
                            :max-count="1"
                            v-model="goodsLogo"
                            name="logo"
                    >
                    </van-uploader>
                </van-col>

                <van-col span="19">
                    <van-uploader
                            :after-read="afterReadUpload"
                            preview-size="55px"
                            class="van-uploader-imgs"
                            multiple
                            :max-count="5"
                            v-model="goodsImgList"
                            name="image"
                    >
                    </van-uploader>
                </van-col>

            </van-row>
            <!--商品图片-->




            <van-row>
                <van-cell
                        title="请简单介绍商品"
                        icon="/__FRONT__/images/icon/goods-detail.png"
                        is-link
                        :value="isWriteDetail"
                        @click="writeGoodsDetail"
                >
                </van-cell>
            </van-row>


        </div>


        <van-goods-action>
            <van-goods-action-button
                    type="danger"
                    text="上一步"
                    @click="backFirstStopBtn"
                    style="border-radius: 0px;margin-left: 0px;"
                    color="#33a04a"
            ></van-goods-action-button>
            <van-goods-action-button
                    type="danger"
                    text="下一步"
                    @click="secondStepBtn"
                    style="border-radius: 0px;margin-right: 0px;"
                    color="#fc2820"
            ></van-goods-action-button>
        </van-goods-action>
    </section>
    <!--第二步-->






    <!--第三步-->
    <section v-show="thirdStep">
        <div style="padding-bottom: 55px;">
            <van-row>
                <van-col span="18">
                    <van-cell :border="false" class="job-detail-title-cell">
                        <span class="van-ellipsis job-detail-title" :title="goodsInfo.name">{{goodsInfo.name}}</span>
                    </van-cell>
                    <van-cell  icon="/__FRONT__/images/icon/baozhang.png" :border="false"  class="job-detail-title-cell">
                        <van-tag type="success">平台认证</van-tag>
                    </van-cell>
                    <van-cell :border="false"  class="job-detail-title-cell">
                        <span>商品数：{{goodsInfo.number}}</span>
                    </van-cell>
                </van-col>

                <van-col span="6" class="job-detail-money-cell">
                    <van-tag plain class="job-detail-money">
                        <span class="money-font" style="font-size: 22px;color: #fe9e39;">{{goodsInfo.money}}元</span>
                    </van-tag>
                </van-col>
            </van-row>


            <!--图片轮播-->
            <van-swipe :autoplay="1500" indicator-color="white" :height="180" v-if="thirdStep">
                <van-swipe-item v-for="(item, index) in goodsImgBanner" :key="index" >
                    <van-image :src="item.image" v-lazy="item.image" :lazy-load="false" ></van-image>
                </van-swipe-item>
            </van-swipe>
            <!--图片轮播-->

            <van-divider :style="{borderColor: '#32a14a', padding: '0 16px' }"></van-divider>

            <van-cell :title="getSetp3Location"
                      icon="/__FRONT__/images/icon/location-icon.png"
                      style="padding-top: 0px;"
                      :border="false"
            ></van-cell>


            <van-row>
                <van-cell title="商品信息" icon="/__FRONT__/images/icon/job-detail-icon.png" size="large">
                    <van-icon name="arrow-down"></van-icon>
                </van-cell>
                <van-cell title="商品原价:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/job-type-qt.png"
                          :value="goodsInfo.oprice">
                </van-cell>
                <van-cell title="商品成色:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/goods-chengse.png"
                          :value="goodsInfo.depreciation">
                </van-cell>
                <van-cell title="商品类型:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/job-type-qt.png"
                          :value="goodsInfo.typeName">
                </van-cell>
                <van-cell title="联系人:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/publish-job-contacts.png"
                          :value="goodsInfo.contacts">
                </van-cell>
                <van-cell title="联系方式:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/job-detail-mobile.png"
                          :value="goodsInfo.mobile">
                </van-cell>
                <van-cell title="联系方式[微信]:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/user-setting-wechat.png"
                          :value="goodsInfo.wechat_num">
                </van-cell>
                <van-cell title="联系方式[QQ]:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/qq.png"
                          :value="goodsInfo.qq_num">
                </van-cell>
            </van-row>


            <van-row>
                <van-cell title="商品详情" icon="/__FRONT__/images/icon/job-detail-content.png" size="30px">
                    <van-icon name="arrow-down"></van-icon>
                </van-cell>
                <van-col span="24">
                    <article class="job-detail-article">
                        {{goodsInfo.extendContent}}
                    </article>
                </van-col>
            </van-row>

        </div>



        <van-goods-action>
            <van-goods-action-button
                    type="danger"
                    text="上一步"
                    style="border-radius: 0px;margin-left: 0px;"
                    color="#33a04a"
                    @click="backSecondStopBtn"
            ></van-goods-action-button>
            <van-goods-action-button
                    type="danger"
                    text="保存草稿"
                    style="border-radius: 0px;margin-left: 0px;"
                    color="#737373"
                    @click="saveMarketGoodsDraft"
            ></van-goods-action-button>
            <van-goods-action-button
                    type="danger"
                    text="发布"
                    style="border-radius: 0px;margin-right: 0px;"
                    color="#fc2820"
                    @click="publishMarketGoods"
            ></van-goods-action-button>
        </van-goods-action>
    </section>
    <!--第三步-->








    <!--区域方式选择器-->
    <van-popup
            v-model="showSelectArea"
            position="bottom"
    >
        <van-area
                :area-list="selectArea"
                @cancel="showSelectArea = false"
                @confirm="confirmSelectArea"
        ></van-area>
    </van-popup>
    <!--区域选择器-->

    <!--商品详情-->
    <van-popup
            v-model="showGoodsDetail"
            position="bottom"
            :style="{ height:'100%'}"
    >
        <van-nav-bar title="商品详情" left-arrow @click-left="confirmWriteDetail" left-text="返回" ></van-nav-bar>
        <van-row style="padding: 5px;">
            <van-field
                    v-model="goodsInfoExtend.content"
                    rows="15"
                    autosize
                    type="textarea"
                    maxlength="500"
                    show-word-limit
                    placeholder="友情提示：请简单介绍商品如购买时间、使用次数等让买家有个基本概念，更有利于成交"
                    style="border: 1px solid #b9b9b9;border-radius: 5px;"
            ></van-field>
        </van-row>
        <van-row>
            <van-col span="24">
                <van-button type="primary" size="large" @click="confirmWriteDetail">保存</van-button>
            </van-col>
        </van-row>
    </van-popup>
    <!--商品详情-->


</div>



<script>

    Vue.use(vant.Lazyload);
    var vm = new Vue({
        //挂载点
        el: '#app',
        //数据集合
        data() {
            return {
                currentStep: 0,
                firstStep: true,
                secondStep: false,
                thirdStep: false,

                //用户信息
                userId: {$userId},

                //显示选择地区
                showSelectArea: false,
                selectArea: {},
                //显示二手商品详情
                showGoodsDetail: false,
                //商品类型
                marketType: [],
                //二手商品封面图片
                goodsLogo:[],
                //二手商品展示图片
                goodsImgList:[],
                //二手商品轮播图
                goodsImgBannerList:[],

                //详情详情
                goodsInfo: {
                    id: {$goodsId},
                    tid: 0,
                    name: '',
                    logo: '',
                    image: '',
                    typeName: '',
                    oprice: '',
                    extendContent: '',
                    money: '',
                    number: 1,
                    contacts: '',
                    mobile: '',
                    wechat_num: '',
                    qq_num: '',
                    provinces_id: '',
                    city_id: '',
                    county_id: '',
                    address: '',
                    provinces_name: '',
                },
                //商品扩展表
                goodsInfoExtend:{
                    id:0,
                    market_id: {$goodsId},
                    content:''
                },


                phone:{
                    error: '',
                },

                isPost: false
            }
        },

        //创建时执行 操作
        created : function (){

            //获取二手商品详情
            if (this.goodsInfo.id) {
                var params = {
                    id: this.goodsInfo.id,
                    extend: 'content'
                };
                axiosRequest.get('/api/market/goodsDetail',{params:params}).then(function (response) {
                    if (response.code == 200) {
                        vm.$data.goodsInfo = response.data;
                        vm.$data.goodsInfoExtend = response.data.extendContent;
                        vm.$data.goodsInfo.extendContent = response.data.extendContent.content;
                        vm.$data.goodsInfo.money = parseFloat(vm.$data.goodsInfo.money);
                        vm.$data.goodsInfo.oprice = parseFloat(vm.$data.goodsInfo.oprice);

                        //处理logo图片
                        vm.$data.goodsLogo = [
                            {
                                url: vm.$data.goodsInfo.logo
                            }
                        ];
                        //处理展示图片
                        var tmpGoodsImage = vm.$data.goodsInfo.image.split('|');
                        tmpGoodsImage.forEach(function (item) {
                            if (item) {
                                vm.$data.goodsImgList.push({
                                    url: item
                                });
                            }
                        });

                        vm.fillChoseGoodsType();
                    } else {
                        vant.Toast({
                            message: response.msg,
                            onClose: function () {
                                history.back();
                            }
                        });
                    }
                });
            }




            //获取二手商品类型列表
            axiosRequest.get('/api/market/marketType').then(function (response) {
                if (response.code == 200) {
                    response.data.forEach(function (item) {
                        item.style = '';
                    });
                    vm.$data.marketType = response.data;
                    vm.fillChoseGoodsType();
                } else {
                    vant.Notify({ type: 'danger', message: response.msg });
                }
            });

            //获取系统中开放的地区
            axiosRequest.get('/api/common/openArea').then(function (response) {
                if (response.code == 200) {
                    vm.$data.selectArea = response.data;
                }
            });



        },

        mounted(){
        },

        //计算属性
        computed:{
            getLocation(){
                return this.goodsInfo.provinces_name ? this.goodsInfo.provinces_name : '请选择区域';
            },
            getSetp3Location(){
                return this.goodsInfo.provinces_name + ' ' + this.goodsInfo.address;
            },
            isWriteDetail(){
                if (!this.goodsInfo.extendContent) {
                    return '请填写商品详情';
                } else {
                    return '已填写商品详情';
                }
            },
            //第三步，商品轮播
            goodsImgBanner(){
                if (this.goodsInfo.logo) {
                    this.goodsImgBannerList = [
                        {
                            image: this.goodsInfo.logo
                        }
                    ];
                }
                var goodsImage = this.goodsInfo.image.split('|');
                goodsImage.forEach(function (item) {
                    if (item) {
                        vm.$data.goodsImgBannerList.push({
                            image: item
                        });
                    }
                });

                if (this.goodsImgBannerList.length > 0) {
                    return this.goodsImgBannerList;
                } else {
                    return [
                        {
                            image: '/__FRONT__/images/icon/11.jpg'
                        },
                        {
                            image: '/__FRONT__/images/icon/12.jpg'
                        },
                    ];
                }
            }
        },



        //方法集合 在 `methods` 对象中定义方法
        methods: {
            //返回上一页
            goBack(){
                history.back();
            },
            //检测手机号码
            checkPhoneNum(){
                var reg = /^1(1|3|4|5|6|7|8|9)\d{1}[-]?\d{4}[-]?\d{4}$/;
                if(!reg.test(this.goodsInfo.mobile)){
                    this.phone.error = '请输入正确的电话号码!';
                } else {
                    this.phone.error = '';
                }
            },

            //编辑 - 填充选择好的兼职类型
            fillChoseGoodsType(){
                if (this.goodsInfo.id) {
                    this.marketType.forEach(function (item) {
                        if (item.id == vm.$data.goodsInfo.tid) {
                            item.style = 'chosed-job-type';
                            vm.$data.goodsInfo.typeName = item.name;
                        }
                    });
                }
            },


            clickMarketType(choseItem){
                this.marketType.forEach(function (item) {
                    item.style = '';
                });
                choseItem.style = 'chosed-job-type';
                this.goodsInfo.tid = choseItem.id;
                this.goodsInfo.typeName = choseItem.name;
            },

            //第一步
            firstStepBtn(){
                if (!this.goodsInfo.tid) {
                    vant.Notify({type: 'danger', message: '请先选择商品分类,在进行下一步操作!'});
                    vant.Toast('请先选择商品分类!');

                } else {
                    this.firstStep = false;
                    this.secondStep = true;
                    this.currentStep = 1;
                }
            },
            backFirstStopBtn(){
                this.firstStep = true;
                this.secondStep = false;
                this.currentStep = 0;
            },


            //第二步
            secondStepBtn(){
                var mustNotEmpey = [
                    {
                        field: 'name',
                        errorMsg: '请填写商品!',
                    },
                    {
                        field: 'logo',
                        errorMsg: '请上传商品封面图片！',
                    },
                    {
                        field: 'tid',
                        errorMsg: '请选择商品类别!',
                    },
                    {
                        field: 'oprice',
                        errorMsg: '请填写商品原价！',
                    },
                    {
                        field: 'money',
                        errorMsg: '请填写商品售价!',
                    },
                    {
                        field: 'contacts',
                        errorMsg: '请填写联系人!',
                    },
                    {
                        field: 'mobile',
                        errorMsg: '请填写联系方式!',
                    },
                    {
                        field: 'extendContent',
                        errorMsg: '请填写商品详情!',
                    },
                    {
                        field: 'provinces_name',
                        errorMsg: '请选择所在区域！',
                    },
                ];
                for(var item of mustNotEmpey) {
                    if (!this.goodsInfo[item.field]) {
                        vant.Toast(item.errorMsg);
                        return false;
                    }
                }
                this.secondStep = false;
                this.thirdStep = true;
                this.currentStep = 2;
            },

            backSecondStopBtn(){
                this.thirdStep = false;
                this.secondStep = true;
                this.currentStep = 1;
            },

            //保存到草稿
            saveMarketGoodsDraft(){
                vant.Toast.loading({
                    duration: 0,
                    forbidClick: true,
                    overlay: true,
                    message: '正在保存...'
                });
                var postData = this.getPostData();
                axiosRequest.post('/api/market/saveDraft', postData).then(function (response) {
                    vant.Toast.clear();
                    if (response.code == 200) {
                        vm.$data.goodsInfo.id = response.data.goodsId;
                        vm.$data.goodsInfoExtend.id = response.data.extendId;
                        vant.Toast({
                            message: '已保存为草稿！',
                            onClose(){
                                window.location.href = '/index/Market/publishGoodsList?type=1';
                            }
                        });
                    } else {
                        vant.Toast('保存失败！');
                        vant.Notify({type:'danger', message:response.msg});
                    }
                });
                return true;
            },

            //获取需要提交的数据
            getPostData(){
                return {
                    extendId: this.goodsInfoExtend.id,
                    id: this.goodsInfo.id,
                    tid: this.goodsInfo.tid,
                    contacts: this.goodsInfo.contacts,
                    mobile: this.goodsInfo.mobile,
                    wechat_num: this.goodsInfo.wechat_num,
                    qq_num: this.goodsInfo.qq_num,
                    name: this.goodsInfo.name,
                    logo: this.goodsInfo.logo,
                    image: this.goodsInfo.image,
                    money: this.goodsInfo.money,
                    oprice: this.goodsInfo.oprice,
                    depreciation: this.goodsInfo.depreciation,
                    number: this.goodsInfo.number,
                    extendContent: this.goodsInfo.extendContent,
                    provinces_name: this.goodsInfo.provinces_name,
                    address: this.goodsInfo.address,
                };
            },

            //保存发布
            publishMarketGoods(){
                if (! this.isPost) {
                    vant.Toast.loading({
                        duration: 0,
                        overlay: true,
                        forbidClick: true,
                        message: '正在保存...'
                    });
                    var postData = this.getPostData();
                    axiosRequest.post('/api/market/publishGoods', postData).then(function (response) {
                        vant.Toast.clear();
                        if (response.code == 200) {
                            vm.$data.isPost = true;
                            vant.Toast({
                                message: '发布成功,请等待审核!',
                                onClose(){
                                    window.location.href = '/index/Market/publishGoodsList?type=2';
                                }
                            });
                        } else {
                            vant.Notify({type:'danger', message:response.msg});
                        }
                    });
                }
            },


            /** popup  选择 工具 start */

            //选择兼职地区
            clickShowSelectArea(){
                this.showSelectArea = true;
            },
            confirmSelectArea(item){
                this.goodsInfo.provinces_name = '';
                item.forEach(function(one){
                    vm.$data.goodsInfo.provinces_name += ' ' + one.name;
                });
                this.showSelectArea = false;
            },
            /** popup  选择 工具 start */






            //上传商品图片
            clickShowPhoto(){
                this.showUploadPhoto = true;
            },
            confirmUploadPhoto(){
                this.showUploadPhoto = false;
            },
            afterReadUpload(file, name){
                //上传图片
                var postData = {
                    img: file.content,
                    savePath: 'market/goods/' + this.userId + '/',
                    extend: name.name
                };
                axiosRequest.post('/api/common/uploadImg', postData).then(function (response) {
                    if (response.code == 200) {
                        if (response.data.img) {
                            if (response.data.extend == 'logo') {
                                vm.$data.goodsLogo = [
                                    {'url' : response.data.img}
                                ];
                                vm.$data.goodsInfo.logo = response.data.img;
                            }
                            if (response.data.extend == 'image') {
                                vm.$data.goodsInfo.image += response.data.img + '|';
                            }
                        } else {
                            vant.Toast('上传失败!');
                        }
                    } else {
                        vant.Toast('上传失败!');
                    }
                });

                return true;
            },


            //展示填写兼职详情
            writeGoodsDetail(){
                this.showGoodsDetail = true;
            },
            //隐藏标记器
            confirmWriteDetail(){
                this.showGoodsDetail = false;
                this.goodsInfo.extendContent = this.goodsInfoExtend.content;
            },
            //获取商品详情填写内容
            updateGoodsContent: function (data) {
                this.goodsInfoExtend.content = data;
                this.goodsInfo.extendContent = data;
            },
        }

    });
</script>

{include file="common/foot-bottom" /}
